<?php


function hash_password($pw,$salt = NULL){
    if($salt === NULL){
        $salt = substr(md5(uniqid(rand(),TRUE)), SALT_LENGTH);
    }else{
        $salt = substr($salt, 0, SALT_LENGTH);
    }
    return $salt.sha1($salt.$pw);
}

?>
